﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Dao;

namespace Domain
{
    /// <summary>
    /// 宝物
    /// </summary>
   public partial class Treasure
    {
       public static Dictionary<int,Treasure> Treasures=new Dictionary<int, Treasure>(); 
       public int Id { get; set; }
       public string Name { get; set; }
       /// <summary>
       /// 类型。1商品，2宝物
       /// </summary>
       public short Type { get; set; }
       /// <summary>
       /// 图片编号
       /// </summary>
       public string PicNumber { get; set; }
       /// <summary>
       /// 是否可用
       /// </summary>
       public bool IsAvailable { get; set; }
       /// <summary>
       /// 是否支持多个
       /// </summary>
       public bool IsMutilate { get; set; }
       /// <summary>
       /// 分组
       /// </summary>
       public int Group { get; set; }
       /// <summary>
       /// 出现时间
       /// </summary>
       public short AppearYear { get; set; }
       public string Description { get; set; }
       public short StrengthAdd { get; set; }
       public short CommanderAdd { get; set; }
       public short IntelligenceAdd { get; set; }
       public short PoliticsAdd { get; set; }
       /// <summary>
       /// 增加忠诚度
       /// </summary>
       public short LoyaltyAdd { get; set; }
       /// <summary>
       /// 商品价格
       /// </summary>
       public int Price { get; set; }
       public static void Load()
       {
           DataTable tb = TreasureDao.SelectAllTreasure("194_QXGJ.s3db");
           for (int i = 0; i < tb.Rows.Count; i++)
           {
               DataRow dr = tb.Rows[i];
               Treasure treasure = new Treasure();
               treasure.Id = Convert.ToInt16(dr["Id"]);
               treasure.Name = dr["Name"].ToString();
               treasure.PicNumber = dr["PicNumber"].ToString();
               treasure.IsAvailable = Convert.ToBoolean(dr["IsAvailable"]);
               treasure.Type = Convert.ToInt16(dr["Type"]);
               treasure.IsMutilate = Convert.ToBoolean(dr["IsMutilate"]);
               treasure.Group = Convert.ToInt32(dr["Group"]);
               treasure.AppearYear = Convert.ToInt16(dr["AppearYear"]);
               treasure.Description =dr["Description"].ToString();
               treasure.StrengthAdd = Convert.ToInt16(dr["StrengthAdd"]);
               treasure.CommanderAdd = Convert.ToInt16(dr["CommanderAdd"]);
               treasure.IntelligenceAdd = Convert.ToInt16(dr["IntelligenceAdd"]);
               treasure.PoliticsAdd = Convert.ToInt16(dr["PoliticsAdd"]);
               treasure.LoyaltyAdd = Convert.ToInt16(dr["LoyaltyAdd"]);
               treasure.Price = Convert.ToInt32(dr["Price"]);
               Treasures.Add(treasure.Id, treasure);
           }
       }
    }
}
